package com.example.bms.user.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.example.bms.user.entity.StaffEntity;
import com.example.bms.user.service.StaffService;
import com.example.common.utils.PageUtils;
import com.example.common.utils.R;



/**
 * 
 *
 * @author Jiang
 * @email 337262603@qq.com
 * @date 2022-01-29 23:14:25
 */
@RestController
@RequestMapping("user/staff")
@CrossOrigin
public class StaffController {
    @Autowired
    private StaffService staffService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("user:staff:list")
        public R list(@RequestParam Map<String, Object> params){
        PageUtils page = staffService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{sid}")
    //@RequiresPermissions("user:staff:info")
    public R info(@PathVariable("sid") Integer sid){
		StaffEntity staff = staffService.getById(sid);
        return R.ok().put("staff", staff);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("user:staff:save")
    public R save(@RequestBody StaffEntity staff){
		staffService.save(staff);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("user:staff:update")
    public R update(@RequestBody StaffEntity staff){
		staffService.updateById(staff);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("user:staff:delete")
    public R delete(@RequestBody Integer[] sids){
		staffService.removeByIds(Arrays.asList(sids));

        return R.ok();
    }

}
